package com.lanou.utp.advice;

import com.lanou.utp.advice.exception.MyException;
import com.lanou.utp.entity.ResponseData;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice(basePackages = "com.lanou.utp")
public class GlobalExceptionAdvice {

    @ExceptionHandler(MethodArgumentNotValidException.class)
    public ResponseData methodArgumentNotValidException(MethodArgumentNotValidException ex) {
        ex.printStackTrace();
        return new ResponseData("409","参数错误,请重新确认");
    }

    @ExceptionHandler(MyException.class)
    public ResponseData runTimeException(MyException ex){
        ex.printStackTrace();
        return new ResponseData("409","请稍后再试");
    }


}
